package cate.game.power;

import cate.common.table.item.hero.row.HeroBaseRow;
import cate.game.attr.PowerAttrPart;
import cate.game.play.part.PlaySide;
import cate.game.play.support.PlayBuildContext;
import cate.game.role.Role;
import cate.game.role.bag.hero.Hero;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;

@NoteClass("所有对战力影响的因素")
public class PowerFactor {

	@NoteField("主角对战力的影响因素")
	private RolePowerFactor role;

	@NoteField("阵型对战力的影响因素")
	private PositionPowerFactor position;


	/**
	 * role的战力因素
	 * @param role
	 */
	public PowerFactor(Role role) {
		if (role == null) {
			return;
		}
		this.role = new RolePowerFactor(role);
	}

	/**
	 * role和阵容的战力因素
	 * @param role
	 * @param side
	 * @param funcId
	 */
	public PowerFactor(Role role, PlaySide side,int funcId) {
		this.role = new RolePowerFactor(role);
		this.position = new PositionPowerFactor(role, side,funcId);
	}

	/**
	 * 构建对英雄的战力影响因素
	 * @param ctx
	 * @param hero
	 * @param pos
	 * @return
	 */
	public PowerAttrPart buildHeroPart(PlayBuildContext ctx, Hero hero, byte pos) {
		PowerAttrPart part = new PowerAttrPart();
		HeroBaseRow heroBaseRow = hero.getTpl(ctx);
		if(heroBaseRow!=null){
			if (role != null) {
				part.merge(role.buildHeroPart(heroBaseRow));
			}
			if (position != null) {
				part.merge(position.buildHeroPart(heroBaseRow,pos));
			}
		}
		return part;
	}
}
